﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Model
{
    /// <summary>
    /// 反射帮助类
    /// </summary>
    public class ReflectHelper
    {
        /// <summary>
        /// 调用一个实体的方法
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="methodType"></param>
        public static void InvokeMethod(Object entity, string methodName)
        {
            InvokeMethod(entity, methodName, null);
        }

        public static void InvokeMethod(Object entity,string methodName,params object[] args)
        {
            var method = entity.GetType().GetMethod(methodName, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.SuppressChangeType);
            method?.Invoke(entity, args);
        }
    }
}
